package fr.pub.jamico.midi;

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.ShortMessage;

public class JamicoMessage extends ShortMessage {
	
	/**
	 * Constructor
	 * @param com the command
	 * @param chan the channel number
	 * @param d1 the first data
	 * @param d2 the second data
	 */
	public JamicoMessage(int com, int chan, int d1, int d2) {
		try {
			this.setMessage(com, chan, d1, d2);
		} catch (InvalidMidiDataException e) {
			e.printStackTrace();
		}
	}
	
	public void setChannel(int c) throws InvalidMidiDataException {
		if (c >= 0 && c < 16) {
			this.data[0] -= this.getChannel();
			this.data[0] += c;
		}
		else {
			throw new InvalidMidiDataException("JAMICO : channel out of bounds");
		}
	}

}
